import 'dart:ui';

extension HexColor on Color {
  static Color fromHex(String? hexString, {double opacity = 1.0}) {
    if (hexString == null || hexString.isEmpty) {
      throw ArgumentError('颜色字符串不能为空');
    }

    hexString = hexString.replaceAll('#', '').replaceAll('0x', '');

    if (hexString.length == 6) {
      hexString = 'FF$hexString'; // 默认不透明度
    } else if (hexString.length != 8) {
      throw ArgumentError('颜色字符串格式错误，应为6位或8位的十六进制值');
    }

    int colorInt = int.parse(hexString, radix: 16);
    return Color(colorInt).withOpacity(opacity);
  }
}

Color line = HexColor.fromHex('#E0E0E0');

class ColorEums {
  static const Color primary = Color(0xFF000000);
  static const Color secondary = Color(0xFF000000);
  static const Color tertiary = Color(0xFF000000);
  static const Color background = Color.fromARGB(255, 245, 245, 245);

  static const Color app_main = Color(0xFF4688FA);
  static const Color dark_app_main = Color(0xFF3F7AE0);

  static const Color bg_color = Color(0xfff1f1f1);
  static const Color dark_bg_color = Color(0xFF18191A);

  static const Color material_bg = Color(0xFFFFFFFF);
  static const Color dark_material_bg = Color(0xFF303233);

  static const Color text = Color(0xFF333333);
  static const Color dark_text = Color(0xFFB8B8B8);

  static const Color text_gray = Color(0xFF999999);
  static const Color dark_text_gray = Color(0xFF666666);

  static const Color text_gray_c = Color(0xFFcccccc);
  static const Color dark_button_text = Color(0xFFF2F2F2);

  static const Color bg_gray = Color(0xFFF6F6F6);
  static const Color dark_bg_gray = Color(0xFF1F1F1F);

  static const Color line = Color(0xFFEEEEEE);
  static const Color dark_line = Color(0xFF3A3C3D);

  static const Color red = Color(0xFFFF4759);
  static const Color dark_red = Color(0xFFE03E4E);

  static const Color text_disabled = Color(0xFFD4E2FA);
  static const Color dark_text_disabled = Color(0xFFCEDBF2);

  static const Color button_disabled = Color(0xFF96BBFA);
  static const Color dark_button_disabled = Color(0xFF83A5E0);

  static const Color unselected_item_color = Color(0xffbfbfbf);
  static const Color dark_unselected_item_color = Color(0xFF4D4D4D);

  static const Color bg_gray_ = Color(0xFFFAFAFA);
  static const Color dark_bg_gray_ = Color(0xFF242526);

  static const Color gradient_blue = Color(0xFF5793FA);
  static const Color shadow_blue = Color(0x805793FA);
  static const Color orange = Color(0xFFFF8547);
}
